Main Tab 1

Column

Column Tab 1

# A tibble: 3,352 × 43
   created_at               id  id_str full_text trunc…¹ displ…² entit…³ metad…⁴
   <dttm>                <dbl>   <dbl> <chr>     <lgl>     <dbl> <lgl>   <lgl>  
 1 2022-11-29 21:35:21 1.60e18 1.60e18 "The #Br… FALSE        64 NA      NA     
 2 2022-11-28 22:59:08 1.60e18 1.60e18 "It's ni… FALSE       140 NA      NA     
 3 2022-11-28 20:59:16 1.60e18 1.60e18 "This ce… FALSE        93 NA      NA     
 4 2022-11-30 13:32:57 1.60e18 1.60e18 "This se… FALSE       125 NA      NA     
 5 2022-11-30 13:31:34 1.60e18 1.60e18 "11-30-2… FALSE        90 NA      NA     
 6 2022-11-30 13:29:55 1.60e18 1.60e18 "Rob Wil… FALSE        49 NA      NA     
 7 2022-11-30 13:28:11 1.60e18 1.60e18 "This se… FALSE       110 NA      NA     
 8 2022-11-30 13:22:45 1.60e18 1.60e18 "☘ @Gran… FALSE       141 NA      NA     
 9 2022-11-30 13:22:18 1.60e18 1.60e18 "Satin L… FALSE       263 NA      NA     
10 2022-11-30 13:11:54 1.60e18 1.60e18 "If the … FALSE        95 NA      NA     
# … with 3,342 more rows, 35 more variables: source <chr>,
#   in_reply_to_status_id <dbl>, in_reply_to_status_id_str <dbl>,
#   in_reply_to_user_id <dbl>, in_reply_to_user_id_str <dbl>,
#   in_reply_to_screen_name <chr>, geo <lgl>, coordinates <lgl>, place <lgl>,
#   contributors <lgl>, is_quote_status <lgl>, retweet_count <dbl>,
#   favorite_count <dbl>, favorited <lgl>, retweeted <lgl>, lang <chr>,
#   possibly_sensitive <lgl>, quoted_status_id <dbl>, …

Column Tab 2

created_at id id_str full_text truncated display_text_range entities metadata source in_reply_to_status_id in_reply_to_status_id_str in_reply_to_user_id in_reply_to_user_id_str in_reply_to_screen_name geo coordinates place contributors is_quote_status retweet_count favorite_count favorited retweeted lang possibly_sensitive quoted_status_id quoted_status_id_str quoted_status text favorited_by scopes display_text_width retweeted_status quoted_status_permalink quote_count timestamp_ms reply_count filter_level query withheld_scope withheld_copyright withheld_in_countries possibly_sensitive_appealable
2022-11-29 21:35:21 1.597781e+18 1.597781e+18 The #Bruins and #Celtics are a combined 36-7. That’s just silly. FALSE 64 NA NA Twitter for iPhone NA NA NA NA NA NA NA NA NA FALSE 63 905 FALSE FALSE en NA NA NA NA The #Bruins and #Celtics are a combined 36-7. That’s just silly. NA NA NA NA NA NA NA NA NA NA NA NA NA NA
2022-11-28 22:59:08 1.597440e+18 1.597440e+18 It’s nice having veteran Malcolm Brogdon around to remind the #Celtics young stars the grass isn’t always greener… https://t.co/vrlu8Bt5Ph FALSE 140 NA NA Twitter Web App NA NA NA NA NA NA NA NA NA FALSE 62 635 FALSE FALSE en FALSE NA NA NA It’s nice having veteran Malcolm Brogdon around to remind the #Celtics young stars the grass isn’t always greener… https://t.co/vrlu8Bt5Ph NA NA NA NA NA NA NA NA NA NA NA NA NA NA
2022-11-28 20:59:16 1.597410e+18 1.597410e+18 This celebration’s gonna be a really popular #Celtics gif for a while https://t.co/FUXzfbKHqI FALSE 93 NA NA Twitter Web App NA NA NA NA NA NA NA NA NA FALSE 24 506 FALSE FALSE en FALSE NA NA NA This celebration’s gonna be a really popular #Celtics gif for a while https://t.co/FUXzfbKHqI NA NA NA NA NA NA NA NA NA NA NA NA NA NA
2022-11-30 13:32:57 1.598022e+18 1.598022e+18 This season, Al Horford is averaging 11.7 PPG, 2.7 AST, 7.3 REB, and 2 3PT returning from an absent game

#Celtics #AlHorford |FALSE | 125|NA |NA |Twitter Web App | NA| NA| NA| NA|NA |NA |NA |NA |NA |FALSE | 0| 0|FALSE |FALSE |en |NA | NA| NA|NA |This season, Al Horford is averaging 11.7 PPG, 2.7 AST, 7.3 REB, and 2 3PT returning from an absent game

#Celtics #AlHorford |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA | |2022-11-30 13:31:34 | 1.598022e+18| 1.598022e+18|11-30-22: NBA Play Of The Day 🏀

FOLLOW ME 🤝 #heat #Celtics

Retweet to share with others https://t.co/gKOtUxWeig |FALSE | 90|NA |NA |Twitter for iPhone | NA| NA| NA| NA|NA |NA |NA |NA |NA |FALSE | 0| 1|FALSE |FALSE |en |FALSE | NA| NA|NA |11-30-22: NBA Play Of The Day 🏀

FOLLOW ME 🤝 #heat #Celtics

Retweet to share with others https://t.co/gKOtUxWeig |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA | |2022-11-30 13:29:55 | 1.598022e+18| 1.598022e+18|Rob Williams FIVE on FIVE scrimmaging… #Celtics https://t.co/0GkSjzSpAQ |FALSE | 49|NA |NA |Twitter Web App | NA| NA| NA| NA|NA |NA |NA |NA |NA |TRUE | 3| 15|FALSE |FALSE |en |FALSE | 1.597989e+18| 1.597989e+18|NA |Rob Williams FIVE on FIVE scrimmaging… #Celtics https://t.co/0GkSjzSpAQ |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |NA |

Column Tab 3

Column

Row 1

Row 2

Main Tab 2

Column

1. Plotly for R

Plotly is an R package for creating interactive web-based graphs via plotly’s JavaScript graphing library, plotly.js.

The plotly R package serializes ggplot2 figures into Plotly’s universal graph JSON. plotly::ggplotly will crawl the ggplot2 figure, extract and translate all of the attributes of the ggplot2 figure into JSON (the colors, the axes, the chart type, etc), and draw the graph with plotly.js. Furthermore, you have the option of manipulating the Plotly object with the style function.

2. Customizing the Layout

Since the ggplotly() function returns a plotly object, we can manipulate that object in the same way that we would manipulate any other plotly object. A simple and useful application of this is to specify interaction modes, like plotly.js’ layout.dragmode for specifying the mode of click+drag events.

3. Example

library(plotly)
df <- data.frame(x=c(1, 2, 3, 4), y=c(1, 5, 3, 5), group=c('A', 'A', 'B', 'B'))
p <- ggplot(data=df, aes(x=x, y=y, colour=group)) + geom_point()
ggplotly(p)

Column

Top Emojis in the Tweets

Top Emojis in the Tweets (Colorized)

M

Visualizations

Column

Frequency Chart

Top Emojis in the Tweets

Top Emojis in the Tweets (Colorized)

---
title: "#Celtics Tweets"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    logo: logo.png
    source_code: embed
    social: menu
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE)
```

```{r, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)
library(knitr)
library(DT)
library(shiny)
library(packrat)
library(rsconnect)
library(rtweet) 
library(tidytext)
library(ggpubr) 
library(lubridate)
```


```{r, include=FALSE, eval=FALSE}
keyword_search = '#Celtics'

df <- search_tweets(q = keyword_search, 
                        n = Inf, # number of tweets
                        include_rts = FALSE,
                        `-filter` = "replies",
                        lang = "en") %>% 
  mutate(created_at = ymd_hms(format(created_at, tz = "US/Eastern")))

write_csv(df, 'final_twitter_data.csv')
```


```{r}
# Create Charts
df <- read_csv('final_twitter_data.csv')

p <- ts_plot(df, "hours") +
  labs(x = NULL, y = NULL,
       title = "Frequency of #Celtics Tweets by Time",
       subtitle = paste0(format(min(df$created_at), "%d %B %Y"), " to ", format(max(df$created_at),"%d %B %Y")),
       caption = "Data collected from Twitter's REST API via rtweet") +
  theme_minimal()

library(emo)
p1 <- df %>%
  mutate(emoji = ji_extract_all(text)) %>%
  unnest(cols = c(emoji)) %>%
  count(emoji, sort = TRUE) %>%
  head(5) %>% 
  ggplot(aes(y=reorder(emoji,n), x=n)) +
  geom_col()+
  theme(axis.text.y = element_text(size = 40))+
  labs(x = 'Top Emojis in the Tweets', y = '')
```

{.sidebar}
=======================================================================

### 1. Boston Celtics

The Boston Celtics season has been off to a very strong start. Being the top team in the Eastern Conference, there is plenty of data to work with for #Celtics tweets.

### 2. Flexdashboard and Plotly

This interactive uses `flexdashboard` and `plotly` to visualize the data. 

Main Tab 1
=======================================================================

Column {data-width=500, .tabset}
-----------------------------------------------------------------------

### Column Tab 1

```{r}
df
```


### Column Tab 2

```{r}
kable(head(df))
```


### Column Tab 3

```{r}
datatable(df, options = list(
  pageLength = 25
))
```


Column {data-width=500}
-----------------------------------------------------------------------

### Row 1

```{r}
p
```

### Row 2

```{r}
ggplotly(p)
```


Main Tab 2
=======================================================================

Column {data-width=500}
-----------------------------------------------------------------------

#### 1. Plotly for R

Plotly is an R package for creating interactive web-based graphs via plotly's JavaScript graphing library, plotly.js.

The plotly R package serializes ggplot2 figures into Plotly's universal graph JSON. plotly::ggplotly will crawl the ggplot2 figure, extract and translate all of the attributes of the ggplot2 figure into JSON (the colors, the axes, the chart type, etc), and draw the graph with plotly.js. Furthermore, you have the option of manipulating the Plotly object with the style function.


#### 2. Customizing the Layout

Since the ggplotly() function returns a plotly object, we can manipulate that object in the same way that we would manipulate any other plotly object. A simple and useful application of this is to specify interaction modes, like plotly.js' layout.dragmode for specifying the mode of click+drag events.


#### 3. Example

```{r, echo=TRUE, eval=TRUE}
library(plotly)
df <- data.frame(x=c(1, 2, 3, 4), y=c(1, 5, 3, 5), group=c('A', 'A', 'B', 'B'))
p <- ggplot(data=df, aes(x=x, y=y, colour=group)) + geom_point()
ggplotly(p)
```



Column {data-width=500}
-----------------------------------------------------------------------

### Top Emojis in the Tweets

```{r}
p1
```

### Top Emojis in the Tweets (Colorized)

```{r}
ggplotly(p1)
```

M
```{r, include=FALSE, eval=FALSE}
rsconnect::setAccountInfo(name='pollacksam', token='F6052A2FC4D2AF2EBE0C0F7E7FE96232', secret='7KhO98PHpOrj4NubfNWJFIOVb8EDdWpf5dez/9Nb')

library(rsconnect)
    rsconnect::deployApp('flex_template.Rmd')
```

Visualizations
=======================================================================

Column {data-width=500}
-----------------------------------------------------------------------

### Frequency Chart

```{r}
ggplotly(p)
```

### Top Emojis in the Tweets

```{r}
p1
```

### Top Emojis in the Tweets (Colorized)

```{r}
ggplotly(p1)
```